<template>
  <div class="project1">
    <cheader :pageIndex="pageIndex"></cheader>
    <!-- <img src="./banner.png" alt="" class="banner"> -->
    <div class="jdBg">
      <img src="@/common/img/bg.png" alt="" class="bg">
      <img src="./banner.png" alt="" class="title">
    </div>
    <div class="pen">
      <div class="p1-title">
        <div class="tWrap">
          <div class="t">
            <img src="@/common/img/ball1.png" alt="">
            <h2>"以笔为旗, 书写大爱"</h2>
            <i></i>
          </div>
        </div>
        <div class="bWrap">
          <div class="b">
            <h3>书法作品大合集</h3>
          </div>
        </div>
      </div>
      <div class="s1" v-if="penArr1.length>1">
        <swiper :options="swiper1Option" ref="s1Swiper">
          <!-- slides -->
          <swiper-slide v-for="item in penArr1" :key="item.id" :data-did='item.id' :style="{backgroundImage: 'url('+ item.cover +')'}">
            <div class="title" :data-did='item.id'>
              <span :data-did='item.id'>
                <img src="@/common/img/quotes1.png" alt="">
                {{item.title.length>8?item.title.substring(0, 8)+'...' : item.title}}
                <img src="@/common/img/quotes2.png" alt="" v-if="item.title.length<8">
              </span>
            </div>
            <!-- <img :src="item.cover" alt="" :data-did='item.id'> -->
            <font-awesome-icon icon="pen" class="icon"/>
          </swiper-slide>
        </swiper>
        <div class="fake1"></div>
        <div class="fake2"></div>
      </div>
      <div class="s2" ref="s2Wrap">
        <div class="s2Content" ref="s2Content">
          <ul>
            <li v-for="item in penArr2" :key="item.id" :data-did='item.id' :style="{backgroundImage: 'url('+ item.cover +')'}" @click="goToDetail(0, 0, item.id)">
              <div class="cover"></div>
              <h3>{{item.title.length>8?item.title.substring(0, 8)+'...' : item.title}}</h3>
            </li>
          </ul>
          <button v-if="penArr2.length" @click="goToList(0, 0, 0, '')">查看更多</button>
        </div>
      </div>
    </div>
    <div class="draw">
      <div class="p1-title">
        <div class="tWrap">
          <div class="t">
            <img src="@/common/img/ball1.png" alt="">
            <h2>"丹青妙手，聚暖生春"</h2>
            <i></i>
          </div>
        </div>
        <div class="bWrap">
          <div class="b">
            <h3>平面绘画作品大合集</h3>
          </div>
        </div>
      </div>
      <div class="s3" ref="s3Wrap">
        <div class="s3Content" ref="s3Content">
          <ul>
            <li v-for="item in drawArr1" :key="item.id" :data-did='item.id' :style="{backgroundImage: 'url('+ item.cover +')'}" @click="goToDetail(0, 1, item.id)">
              <div class="cover"></div>
              <font-awesome-icon :icon="['far', 'image']" class="icon"/>
              <h3>{{item.title.length>8?item.title.substring(0, 8)+'...' : item.title}}</h3>
            </li>
          </ul>
          <button v-if="drawArr1.length" @click="goToList(0, 1, 1, '')">查看更多</button>
        </div>
      </div>
    </div>
    <div class="poem">
      <div class="p1-title">
        <div class="tWrap">
          <div class="t">
            <img src="@/common/img/ball1.png" alt="">
            <h2>"字字珠玑，心灯长明"</h2>
            <i></i>
          </div>
        </div>
        <div class="bWrap">
          <div class="b">
            <h3>诗词作品</h3>
          </div>
        </div>
      </div>
      <div class="s5" ref="s5Wrap">
        <div class="s5Content" ref="s5Content">
          <ul>
            <li v-for="item in poemArr" :key="item.id" :data-did='item.id' :style="{backgroundImage: 'url('+ item.cover +')'}" @click="goToDetail(0, 2, item.id)">
              <div class="cover"></div>
              <h3>
                <img src="@/common/img/quotes1.png" alt="">
                {{item.title.length>4?item.title.substring(0, 4)+'...' : item.title}}
                <img src="@/common/img/quotes2.png" alt="" v-if="item.title.length<4">
              </h3>
            </li>
          </ul>
          <button v-if="poemArr.length" @click="goToList(0, 2, 2, '')">查看更多</button>
        </div>
      </div>
    </div>
    <div class="mv">
      <div class="p1-title">
        <div class="tWrap">
          <div class="t">
            <img src="@/common/img/ball1.png" alt="">
            <h2>"匠心独具，心系疫情"</h2>
            <i></i>
          </div>
        </div>
        <div class="bWrap">
          <div class="b">
            <h3>原创MV作品大合集</h3>
          </div>
        </div>
      </div>
      <ul>
        <li v-for="item in mvArr" :key="item.id" :data-did='item.id' @click="goToDetail(0, 3, item.id)">
          <div class="t" :style="{backgroundImage: 'url('+ item.cover +')'}">
            <div class="cover"></div>
            <div class="info">
              <font-awesome-icon :icon="['fas', 'video']" class="icon"/>
              <span>{{item.durtime}}</span>
            </div>
          </div>
          <div class="b">
            <h2>{{item.title.length>9?item.title.substring(0, 9)+'...' : item.title}}</h2>
          </div>
        </li>
      </ul>
      <button v-if="mvArr" @click="goToList(0, 3, 3, '')">查看更多</button>
    </div>
    <cfooter></cfooter>
  </div>
</template>
<script>
import cheader from '@/components/cheader/cheader'
import cfooter from '@/components/cfooter/cfooter'
import { swiper, swiperSlide } from 'vue-awesome-swiper'
import api from '@/common/js/api'
import BScroll from 'better-scroll'
import '@/common/css/swiper.min.css'
export default {
  data () {
    return {
      // bg: require('@/common/img/bg.png'),
      pageIndex: 0,
      swiper1Option: {
        effect: 'fade',
        direction: 'vertical',
        loop: true,
        // autoplay: true,
        on: {
          click: (e) => {
            let did = e.target.dataset.did
            if (did) {
              this.goToDetail(0, 0, did)
            } else {
              return false
            }
          }
        }
      },
      penArr1: [],
      penArr2: [],
      drawArr1: [],
      drawArr2: [],
      poemArr: [],
      bigMvArr: [],
      mvArr: []
    }
  },
  computed: {
  },
  created () {
  },
  mounted () {
    // let wH = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
    // this.$refs.pageWrap.style.height = wH - 65 + 'px'
    this.$nextTick(() => {
      this._initScroll()
    })
    api.project1Index().then(res => {
      if (res.data.result === '0') {
        this.penArr1 = res.data.data.calligraphy.big
        this.penArr2 = res.data.data.calligraphy.small
        this.drawArr1 = res.data.data.paint.big
        this.drawArr2 = res.data.data.paint.small
        this.poemArr = res.data.data.potery
        this.bigMvArr = res.data.data.video.big
        this.mvArr = res.data.data.video.small
      }
    }).then(() => {
      this._initScroll()
    })
  },
  components: {
    cheader,
    cfooter,
    swiper,
    swiperSlide
  },
  methods: {
    _initScroll () {
      let penArr2 = this.penArr2
      let drawArr1 = this.drawArr1
      let poemArr = this.poemArr
      console.log(penArr2)
      // this.scroll = new BScroll(this.$refs.pageWrap, {})
      if (penArr2.length) {
        let long = penArr2.length * 140 + 100 + 'px'
        this.$refs.s2Content.style.width = long
        this.scroll = new BScroll(this.$refs.s2Wrap, {
          scrollX: true,
          scrollY: false,
          click: true,
          tap: true,
          eventPassthrough: 'vertical',
          bounce: false
        })
      }
      if (drawArr1.length) {
        let long = drawArr1.length * 140 + 100 + 'px'
        this.$refs.s3Content.style.width = long
        this.scroll = new BScroll(this.$refs.s3Wrap, {
          scrollX: true,
          scrollY: false,
          click: true,
          tap: true,
          eventPassthrough: 'vertical',
          bounce: false
        })
      }

      if (poemArr.length) {
        let long = poemArr.length * 140 + 100 + 'px'
        this.$refs.s5Content.style.width = long
        this.scroll = new BScroll(this.$refs.s5Wrap, {
          scrollX: true,
          scrollY: false,
          click: true,
          tap: true,
          eventPassthrough: 'vertical',
          bounce: false
        })
      }
    },
    // 去专题列表页 (专题几，第几个模块, 后端参数type, 后端参数id)
    goToList (project, blc, postType, postId) {
      this.$router.push({
        name: 'projectList',
        query: {
          project: project,
          blc: blc,
          postType: postType,
          postId: postId
        }
      })
    },
    // 去文章详情页 (专题几，第几个模块, 后端参数id, 后端参数id)
    goToDetail (project, blc, did) {
      console.log(123)
      this.$router.push({
        name: 'projectDetail',
        query: {
          project: project,
          blc: blc,
          did: did
        }
      })
    },
    goJump (e) {
      let did = e.target.dataset.did
      this.goToDetail(0, 2, did)
    }
  }
}
</script>
<style lang="scss" scoped>
  $tjBlue: #59bed9;
  .project1 {
    // height: 300px;
    background: no-repeat top center $tjBlue;
    overflow: hidden;
    .jdBg {
      width: 100%;
      height: 270px;
      // background: green;
      position: relative;
      overflow: hidden;
      .bg {
        width: 375px;
        height: 229px;
        position: absolute;
        top: 0;
        left: 50%;
        margin-left: -187px;
      }
      .title {
        width: 375px;
        height: 205px;
        position: absolute;
        bottom: 0;
        left: 50%;
        margin-left: -187px;
      }
    }
    .p1-title {
      text-align: center;
      .t {
        height: 38px;
        position: relative;
        display: inline-block;
        img {
          position: absolute;
          left: 0;
          top: 0;
          width: 29px;
          height: 29px;
        }
        h2 {
          font-size: 17px;
          color: #fff;
          position: relative;
          top: 11px;
          margin-left: 11px;
          font-weight: bold;
        }
        i {
          width: 5px;
          height: 5px;
          position: absolute;
          right: -6px;
          bottom: 10px;
          background-color: #ffe75f;
        }
      }
      .b {
        display: flex;
        justify-content: space-between;
        position: relative;
        h3 {
          width: 100%;
          font-size: 13px;
          color: #fff;
          position: relative;
          z-index: 3;
          text-align: center;
        }
        i {
          width: 70px;
          height: 24px;
          line-height: 25px;
          text-align: center;
          border-radius: 50px;
          color: #fff;
          font-size: 14px;
          font-style: normal;
          cursor: pointer;
          background-color: rgba($color: #fff, $alpha: .3);
        }
      }
    }
    .pen {
      width: 100%;
      padding-top: 20px;
      padding-bottom: 25px;
      min-height: 380px;
      .p1-title {
        margin-bottom: 15px;
      }
      .s1 {
        margin-bottom: 20px;
        .swiper-container {
          cursor: pointer;
          // background-color: red;
          width: 325px;
          height: 164px;
          border-radius: 10px;
          .swiper-slide {
            // height: 164px;
            overflow: hidden;
            background: center no-repeat;
            background-size: cover;
            .title {
              display: block;
              width: 30px;
              height: 164px;
              // background-image: linear-gradient(#5a5a5a, transparent);
              background-color: rgba($color: #000000, $alpha: 0.6);
              text-align: center;
              color: #fff;
              position: relative;
              z-index: 2;
              span {
                display: block;
                margin: 0 auto;
                padding-top: 5px;
                width: 18px;
                font-size: 12px;
                line-height: 16px;
                img {
                  position: static;
                  width: 15px;
                }
              }
            }
            .icon {
              color: #fff;
              position: absolute;
              right: 10px;
              bottom: 15px;
              font-size: 12px;
            }
            img {
              position: absolute;
              top: 0;
              left: 0;
            }
          }
        }
        .fake1 {
          width: 300px;
          height: 5px;
          background-color: #fff;
          opacity: .4;
          margin: 0 auto;
          border-bottom-left-radius: 26px;
          border-bottom-right-radius: 26px;
        }
        .fake2 {
          width: 275px;
          height: 10px;
          background-color: #fff;
          opacity: .5;
          margin: 0 auto;
          border-bottom-left-radius: 26px;
          border-bottom-right-radius: 26px;
          position: relative;
          top: -5px;
        }
      }
      .s2 {
        width: 100%;
        overflow: hidden;
        .s2Content {
          ul {
            display: inline-block;
            vertical-align: top;
            white-space: nowrap;
            padding-left: 25px;
            li {
              display: inline-block;
              vertical-align: top;
              width: 130px;
              height: 70px;
              font-size: 0px;
              margin-right: 10px;
              border-radius: 10px;
              overflow: hidden;
              background: center no-repeat;
              background-size: cover;
              position: relative;
              .cover {
                position: absolute;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                background-image: linear-gradient(transparent, rgba(0,0,0,0.8));
              }
              h3 {
                color: #fff;
                position: absolute;
                left: 8px;
                bottom: 8px;
                font-size: 12px;
              }
            }
          }
          button {
            padding: 0;
            display: inline-block;
            vertical-align: top;
            width: 25px;
            height: 70px;
            box-sizing: border-box;
            border: 1px solid #fff;
            border-radius: 5px;
            background-color: #24a1c2;
            font-size: 12px;
            color: #fff;
            line-height: 13px;
            text-align: center;
          }
        }
      }
    }
    .draw {
      margin-bottom: 25px;
      min-height: 291px;
      min-height: 146px;
      .p1-title {
        margin-bottom: 15px;
      }
      .s3{
        width: 100%;
        overflow: hidden;
        .s3Content {
          ul {
            display: inline-block;
            vertical-align: top;
            white-space: nowrap;
            padding-left: 25px;
            li {
              display: inline-block;
              vertical-align: top;
              width: 130px;
              height: 225px;
              font-size: 0px;
              margin-right: 10px;
              border-radius: 10px;
              overflow: hidden;
              background: center no-repeat;
              background-size: cover;
              position: relative;
              .cover {
                position: absolute;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                background-image: linear-gradient(transparent, rgba(0,0,0,0.8));
              }
              h3 {
                color: #fff;
                position: absolute;
                left: 8px;
                bottom: 8px;
                font-size: 12px;
              }
              .icon {
                position: absolute;
                left: 13px;
                bottom: 24px;
                font-size: 15px;
                color: #fff;
              }
            }
          }
          button {
            padding: 0;
            display: inline-block;
            vertical-align: top;
            width: 25px;
            height: 225px;
            box-sizing: border-box;
            border: 1px solid #fff;
            border-radius: 5px;
            background-color: #24a1c2;
            font-size: 12px;
            color: #fff;
            line-height: 16px;
            text-align: center;
          }
        }
      }
    }
    .poem {
      margin-bottom: 25px;
      .p1-title {
        margin-bottom: 15px;
      }
      .s5 {
        width: 100%;
        overflow: hidden;
        .s5Content {
          ul {
            display: inline-block;
            vertical-align: top;
            white-space: nowrap;
            padding-left: 25px;
            li {
              display: inline-block;
              vertical-align: top;
              width: 130px;
              height: 100px;
              font-size: 0px;
              margin-right: 10px;
              border-radius: 10px;
              overflow: hidden;
              background: center no-repeat;
              background-size: cover;
              position: relative;
              .cover {
                width: 25px;
                height: 100%;
                position: absolute;
                top: 0;
                left: 0;
                background-image: linear-gradient(#000, transparent);
              }
              h3 {
                color: #fff;
                line-height: 16px;
                position: absolute;
                left: 5px;
                top: 8px;
                text-align: center;
                font-size: 12px;
                word-wrap: break-word;
                writing-mode: vertical-rl;
                letter-spacing: 1px;
                // writing-mode: vertical-rl;
                img {
                  display: inline-block;
                  width: 16px;
                }
              }
            }
          }
          button {
            padding: 0;
            display: inline-block;
            vertical-align: top;
            width: 25px;
            height: 80px;
            box-sizing: border-box;
            border: 1px solid #fff;
            border-radius: 5px;
            background-color: #24a1c2;
            font-size: 12px;
            color: #fff;
            line-height: 15px;
            text-align: center;
          }
        }
      }
    }
    .mv {
      margin-bottom: 22px;
      min-height: 359px;
      .p1-title {
        margin-bottom: 15px;
      }
      ul {
        width: 325px;
        display: flex;
        justify-content: space-between;
        flex-wrap: wrap;
        margin: 0 auto;
        li {
          width: 158px;
          height: 120px;
          // background-color: green;
          border-radius: 5px;
          overflow: hidden;
          margin-bottom: 10px;
          box-shadow: 0 0 5px #333;
          .t {
            width: 158px;
            height: 100px;
            background: center no-repeat;
            background-size: cover;
            position: relative;
            .cover {
              position: absolute;
              top: 0;
              left: 0;
              right: 0;
              bottom: 0;
              background-image: linear-gradient(transparent, rgba(#000, .7));
            }
            .info {
              width: 100%;
              position: absolute;
              bottom: 8px;
              // background-color: green;
              display: flex;
              justify-content: space-between;
              .icon {
                margin-left: 10px;
                color: #fff;
                font-size: 12px;
              }
              span {
                margin-right: 8px;
                color: #fff;
                font-size: 12px;
              }
            }
          }
          .b {
            height: 20px;
            line-height: 20px;
            background-color: #82e1fa;
            h2 {
              color: #095146;
              font-size: 12px;
              font-weight: bolder;
              text-align: center;
            }
          }
        }
      }
      button {
        display: block;
        width: 325px;
        height: 33px;
        line-height: 33px;
        border-radius: 5px;
        background-color: #24a1c2;
        margin: 0 auto;
        border: 1px solid #fff;
        color: #fff;
      }
    }
    .footer {
      height: 90px;
      overflow: hidden;
      background-color: rgba($color: #000000, $alpha: 0.1);
      .content {
        width: 900px;
        line-height: 100px;
        margin: 0 auto;
        display: flex;
        justify-content: space-between;
        color: #fff;
      }
    }
  }
</style>
